﻿// --------------------------------------------------------------------------------------------------------------------- 
// <copyright file="SequenceGenerator.cs" company="Microsoft">
//   Copyright (c) Microsoft Corporation.  All rights reserved. THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
// </copyright>
// <summary>
//   Defines the SequenceGenerator type.
// </summary>
// ---------------------------------------------------------------------------------------------------------------------
namespace EulerProblemsCSharp
{
    using System;
    using System.Collections.Generic;

    /// <summary>
    /// Generates sequences.
    /// </summary>
    public class SequenceGenerator
    {
        /// <summary>
        /// Generates a sequence of integers representing the digits of a given number.
        /// </summary>
        /// <param name="maxToReturn">
        /// The max to return.
        /// </param>
        /// <returns>
        /// Sequence of integers representing the digits of a given number.
        /// </returns>
        public IEnumerable<int> Decimal(int maxToReturn)
        {
            var i = 1;

            while (i <= maxToReturn)
            {
                foreach (var c in i.ToString())
                {
                    yield return Int32.Parse(c.ToString());
                }

                i++;
            }
        }        
    }
}